We can capitalize on the DT package to beautify any data frame output in R Markdown. For the purpose of being quick, let us compare printing out the built in iris dataset using print and the DT::datatable() function.
pacman::p_load(tidyverse, DT) # loading the tidyverse and DT packages
iris %>% head(2) # showing only the first two rows for space purposes
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1 5.1 3.5 1.4 0.2 setosa
## 2 4.9 3.0 1.4 0.2 setosa
datatable(iris, # name of data frame
extensions = c('FixedColumns', 'Buttons'), # extensions used
options = list(
dom = 'Bfrtip', # B is the buttons extension, f filtering input, see https://datatables.net/reference/option/dom
scrollX = TRUE, # scrolling along the x-axis
buttons = c('copy', 'csv', 'excel', 'pdf'), # buttons used from the extension
fixedColumns = list(leftColumns = 1)) ) %>% # fixing the left 1 column (similar to what you do in Excel)
formatRound(columns= c('Sepal.Length', 'Sepal.Width'), digits=0) # from DT, specifying formatting to specific cols
After last class, one of your colleagues informed me that she had issues in installing the timetk package on her Macbook Pro. Given that I do not have a MacBook, I am not able to replicate the error. However, if you are one of these students you have the following options:
Plan A:
Ensure that your MacOS is up to date (see how to update the software on your Mac for more details). Note that per the CRAN Documentation:
(a) R 4.0.3 binary for macOS 10.13 (High Sierra) and higher, signed and notarized package. Contains R 4.0.3 framework, R.app GUI 1.73 in 64-bit for Intel Macs, Tcl/Tk 8.6.6 X11 libraries and Texinfo 6.7. The latter two components are optional and can be ommitted when choosing “custom install”, they are only needed if you want to use the tcltk R package or build package documentation from sources.
(b) Note: the use of X11 (including tcltk) requires XQuartz to be installed since it is no longer part of OS X. Always re-install XQuartz when upgrading your macOS to a new major version.
(c) Important: this release uses Xcode 10.1 and GNU Fortran 8.2. If you wish to compile R packages from sources, you will need to download and GNU Fortran 8.2 - see the tools directory.
Once you have updated your MacOS software, I would recommend uninstalling both RStudio and R (in that order).
Then, I would recommend reinstalling R and RStudio (in that order).
Now, you can attempt to re-install the packages that we used last class (pacman, tidyverse, tidyquant). Hopefully, you will be able to install tidyquant.
If not, I would recommend installing an earlier version of timetk per this GitHub Issue Response. This can be done as follows:
(a) remove.packages(timetk) – assuming it was installed incorrectly.
(b) install.packages('https://cran.r-project.org/src/contrib/Archive/timetk/timetk_2.6.0.tar.gz', repos=NULL, type="source"), which may be the only step you need if (a) is not needed/ returns an error.
Plan B:
I wrote a function that would mimic the output needed from the tidyquant::tq_get(). This function can be brought into your working directory using the following command: source('https://raw.githubusercontent.com/fmegahed/businessForecasting/master/custom_functions/tq_get.R'). Note that you will have to do that for every R session, i.e, you can consider this command to be in lieu of the pacman::p_load(tidyquant) command.